import httpUtil from "../utils/httpUtil"
import dateUtil from "@/utils/dateUtil.js"

const currentVerify = 26

/**
 * 审核版本控制
 */
const isVerify = (successCallBack) => {
	let params = {
		pid: 1,
		ver: currentVerify
	}
	httpUtil.post('/api/Alipayad/shenhe', params, res => {
		if (successCallBack) {
			successCallBack(res.data.is == 1)
		}
	})
}

const is404 = () => {
	let params = {
		a: httpUtil.getA()
	}
	httpUtil.postReturnSource('/api/Alipayad/status', params, res => {
		// res.code = -404
		if (res.code == -404) {
			uni.redirectTo({
				url: '/pages/404/404'
			})
		}
		// console.log('is404', res, res.code)
	})
}


/**
 * 埋点请求 (作废用新的)
 * @deprecated newBuriedPoint 用这个方法
 */
const buriedPoint = (env) => {
	let lastDateTime = dateUtil.getTimeTampByStr('2024-05-21 23:59:59')
	let currentDateTime = dateUtil.getCurrentTimeTamp()

	if (currentDateTime < lastDateTime) {
		let params = {
			a: httpUtil.getA(),
			env,
		}
		httpUtil.postReturnSource('/api/rf/getMpUrl', params)
	}
}

const newBuriedPoint = (proCode) => {
	let params = {
		a: httpUtil.getA(),
		proCode,
	}
	httpUtil.postReturnSource('/api/tongji/tongji0520', params)
}



export default {
	isVerify,
	is404,
	buriedPoint,
	newBuriedPoint,
}